<?php

$params = require(__DIR__ . '/params.php');
Yii::$classMap['Method'] = '@app/libs/Method.php';
Yii::$classMap['UploadFile'] = '@app/libs/upload/UploadFile.php';
Yii::$classMap['Mobile_Detect'] = '@app/libs/Mobile_Detect.php';
$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'modules' => [
        'user' => [
            'class'=>'app\modules\user\UserModule'
        ],
        'cn' => [
            'class'=>'app\modules\cn\CnModule'
        ],
        'admin' => [
            'class'=>'app\modules\admin\AdminModule'
        ],
        'content' => [
            'class'=>'app\modules\content\ContentModule'
        ],
        'exercise' => [
            'class'=>'app\modules\exercise\ExerciseModule'
        ],
        'app' => [
            'class'=>'app\modules\app\AppModule'
        ],
        'applets' => [
            'class'=>'app\modules\applets\AppletsModule'
        ],
        'test' => [
            'class'=>'app\modules\test\TestModule'
        ],

        'weixin' => [

            'class'=>'app\modules\weixin\WeixinModule'

        ],
    ],
    'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => '3ggkbEhqR-n2ASj19BJSpbdvpmbO4NwK',
        ],
         'cache' => [
             'class' => 'yii\caching\MemCache',
             'servers'=> [['host'=>'127.0.0.1','port'=>'11211']]
         ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],

        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'useFileTransport' =>false,//这句一定有，false发送邮件，true只是生成邮件在runtime文件夹下，不发邮件
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.mxhichina.com',  //每种邮箱的host配置不一样
                'username' => 'official@thinkwithu.com',
                'password' => 'Thinku2020',
                'port' => '465',
                'encryption' => 'ssl',
            ],
            'messageConfig'=>[
                'charset'=>'UTF-8',
                'from'=>['official@thinkwithu.com'=>'申友网']
            ],
        ],

        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            //'suffix' => '.html',
            'rules' => [
//                  // 首页
                '' => 'cn/index/index',// 首页
                'calendar.html'=>'cn/calendar/index',// 日历
                'city.html'=>'cn/city/index',// 城市
                'mall.html' => 'cn/course/index',// 首页
                // 'mall/<cate:\d+>/<subject:\d+>/<score:\d+>/<page:\d+>.html' => 'cn/course/index',// 首页
                'course-detail/<id:\d+>.html' => 'cn/course/detail',
                'news-detail/<id:\d+>.html' => 'cn/news/detail',
                'teacher-detail/<id:\d+>.html' => 'cn/teacher/detail',
                'news.html' => 'cn/news/index',
                'amanda.html' => 'cn/news/amanda',
                'news/<cate>.html' => 'cn/news/index',
                'news/<cate:\d+>-<page:\d+>.html' => 'cn/news/index',

                'news-headline/<id:\d+>.html' => 'cn/news/headline',// 头条
                'news-information/<id:\d+>.html' => 'cn/news/information',// 资讯
                'active.html' => 'cn/active/index',
                'course.html' => 'cn/course/system', // 课程体系
                'active-detail/<id:\d+>.html' => 'cn/active/detail',
                'about-us.html' => 'cn/index/about',
                'guide.html' => 'cn/index/guide',
                'ieltstestcenter.html' => 'cn/examroom/index',
                'ieltstestcenter/<city:\d+>.html' => 'cn/examroom/detail',
                'teacher.html' => 'cn/teacher/index',
                'teacher/<seniority:\d+>.html' => 'cn/teacher/index',
                'case.html' => 'cn/case/index',
                'case-detail/<id:\d+>.html' => 'cn/case/detail',
                '404.html' => 'cn/index/not-found',
                'ieltsapp.html' => 'cn/index/app',
                'login.html' => 'cn/login/index',
                'register.html' => 'cn/login/register',
                'xiti.html' => 'cn/exercise/practice',
                'coupon.html' => 'cn/coupon/index',

                'exercise.html' => 'cn/exercise/exercise-topic',// 做题练习

                // 个人中心
                'ucenter.html' => 'cn/ucenter/index',
                'member.html' => 'cn/ucenter/member',
                'timetable.html' => 'cn/ucenter/timetable',
                'member/<page:\d+>.html' => 'cn/ucenter/member',
                'password.html' => 'cn/ucenter/password',
                'order.html' => 'cn/ucenter/order',
                'order/<type:\d+>/<page:\d+>.html' => 'cn/ucenter/order',
                'my-course.html' => 'cn/ucenter/course',
                'my-course/<type:\d+>/<page:\d+>.html' => 'cn/ucenter/course',
                'record.html' => 'cn/ucenter/record',
                'message.html' => 'cn/ucenter/message',
                'message/<status:\d+>/<page:\d+>.html' => 'cn/ucenter/message',
                'statement.html' => 'cn/index/statement',
                //模考
                'mock.html' => 'cn/mock/list',
                'mock/guide.html' => 'cn/mock/guide',
                'mock/listen.html' => 'cn/mock/listen',
                'mock/read.html' => 'cn/mock/read',
                'mock/write.html' => 'cn/mock/write',
                'mock/record.html' => 'cn/ucenter/mock-record',
                'mock/detail.html' => 'cn/mock/detail',
                'mock/result.html' => 'cn/mock/result',
                'collect.html' => 'cn/ucenter/collect-list',
                'evaluation.html' => 'cn/evaluation/get-paper',
                'evaluation/notice.html' => 'cn/evaluation/get-subject',
                'evaluation/question.html' => 'cn/evaluation/get-question',
                'evaluation/result.html' => 'cn/evaluation/result',
            ],
        ],

        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'db' => require(__DIR__ . '/db.php'),
        'logindb' => require(__DIR__ . '/logindb.php'),
        'ucdb' => require(__DIR__ . '/ucdb.php'),
    ],
    'params' => $params,
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = 'yii\debug\Module';

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = 'yii\gii\Module';
}

return $config;
